 $(function () {
                var token=localStorage.phone;

                $.ajax({
                    url:"https://newapp.icandrive.cn/api/set.php",
                    type:'post',
                    dataType:'json',
                    data:{token:token},
                    success: function (data) {
                        if(data.status==200){
                            $(data.dataing).each(function () {


                                //页面加载获取登陆电话号码  在index查询到的
                                var	change_hidden_phone = (this.id_number).substring(0,10) + "*****" + (this.id_number).substring(this.id_number.length - 3);


                                $('.portrait').attr('src',this.photo);
                                $('.name').val(this.user_name);
                                $('.id_number').val(change_hidden_phone);
                                $('.phone').val(this.phone);
                                $('.work').val(this.work);
                            })
                        }
                    },
                    error: function () {
                    }
                })
                $('.name img').click(function () {
                    $('.name input[type=file]').click();
                })
            })

            var xhr;

            function createXMLHttpRequest() {
                if (window.ActiveXObject) {
                    xhr = new ActiveXObject("Microsoft.XMLHTTP");
                } else if (window.XMLHttpRequest) {
                    xhr = new XMLHttpRequest();
                }
            }

            function UpladFile() {
                var f=document.getElementById("file").value;
                if(!/\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(f))
                {
                    layer.msg("请选择正确格式的图片");
                    return false;
                }
                var token=localStorage.phone;
                var fileObj = document.getElementById("file").files[0];
                var FileController = 'https://newapp.icandrive.cn/api/student_photo.php?token='+token;
                var form = new FormData();
                form.append("myfile", fileObj);
                createXMLHttpRequest();
                xhr.onreadystatechange = handleStateChange;
                xhr.open("post", FileController, true);
                xhr.send(form);
            }
            function handleStateChange() {
                if (xhr.readyState == 4) {
                    if (xhr.status == 200 || xhr.status == 0) {
                        var result = xhr.responseText;
                        var json = eval("(" + result + ")");
                        setTimeout(function(){
                            history.go(0)
                        },2000)

                    }
                }
            }
            function save_self(){
                var token=localStorage.phone;
                var work=$('.work').val();
                //        var phone=$('.phone').val();


                $.ajax({
                    url:'https://newapp.icandrive.cn/api/set_self.php',
                    data:{token:token,work:work},
                    dataType:'json',
                    type:'post',
                    success: function (data) {
                        if(data.status==200){
                            alert('保存成功')
                        }else{
                            alert('系统繁忙，请稍后再试')
                            history.go(0)
                        }

                    },
                    error: function () {

                    }

                })
            }
